home *** CD-ROM | disk | FTP | other *** search
- UNIT StrTool;
-
- INTERFACE
-
- USES Strings;
-
- function STRHasWildcards(FileName: PChar): Boolean;
- Function STRInstring(P1, P2 : Pchar) : Boolean;
- Function STRCheckSub(Srch : PChar; Pre : PChar; Switch : Byte) : Boolean;
-
- IMPLEMENTATION
-
- function STRHasWildcards(FileName: PChar): Boolean;
- begin
- STRHasWildcards := (StrScan(FileName, '*') <> nil)
- { or (StrScan(FileName, '?') <> nil)};
- end;
-
- Function STRInstring(P1, P2 : Pchar) : Boolean;
- VAR
- Count : Integer;
- Check : Integer;
- P1len : Integer;
- P2Len : Integer;
- TestChar : Char;
- BEGIN
- P1Len := StrLen(P1);
- P2Len := StrLen(P2);
- FOR Count := 0 to (P2Len-P1Len) do BEGIN
- Check := 0;
- Repeat
- IF ((Count+Check) <= P2Len) THEN
- {WriteLn(P1[Check],' - > ',P2[Count+Check]);}
- TestChar := P2[Count+Check];
- IF TestChar = 'Σ' Then TestChar := '─';
- IF TestChar = '÷' Then TestChar := '╓';
- IF TestChar = 'ⁿ' Then TestChar := '▄';
- IF (P1[Check] = TestChar) THEN Inc(Check)
- ELSE Check := -1;
- Until ((Check < 0) OR (Check >= P1Len));
- IF (Check = P1Len) THEN BEGIN
- STRInstring := TRUE;
- {
- WriteLn('Whoopee...');
- }
- Exit;
- END;
- END;
- STRInstring := False;
- END;
-
- Function STRCheckSub(Srch : PChar; Pre : PChar; Switch : Byte) : Boolean;
- BEGIN
-
- IF (StrLen(Srch) = 0) THEN BEGIN
- Case Switch of
- 0 : StrCheckSub := True; { AND }
- 1 : StrCheckSub := True; { OR }
- 2 : StrCheckSub := True; { Not }
- END;
- Exit;
- END;
-
- IF ((StrLen(Srch) <> 0) AND (StrLen(Pre) = 0)) THEN BEGIN
- Case Switch of
- 0 : StrCheckSub := FALSE; { AND }
- 1 : StrCheckSub := FALSE; { OR }
- 2 : StrCheckSub := TRUE; { Not }
- END;
- Exit;
- END;
-
- IF (STRInstring(StrUpper(Srch),StrUpper(Pre)) =True) Then
- Case Switch of
- 0 : StrCheckSub := True; { AND }
- 1 : StrCheckSub := True; { OR }
- 2 : StrCheckSub := False; { Not }
- END
- ELSE
- Case Switch of
- 0 : StrCheckSub := False; { AND }
- 1 : StrCheckSub := False; { OR }
- 2 : StrCheckSub := True; { Not }
- END;
- END;
-
-
-
- BEGIN
- END.
-